home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / H-I / HyperHackers.cpt / Hyper-Hackers Queue 1.0 / card_36874.txt < prev    next >
Text File  |  1989-02-26  |  4KB  |  112 lines

  1. -- card: 36874 from stack: in.0
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 3797
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 1
  9. ----- text -----
  10.  
  11. From: edmoy@violet.berkeley.edu
  12.  
  13. Date: 10 Mar 88 19:28:34 GMT
  14.  
  15. >I want to copy the contents in fields of one stack to an updated version
  16. >new stack. I used a script like the one here...
  17.  
  18. >on copyStuff - executed from a button in the source stack
  19. >  put the number of cards into numCards
  20. >  repeat with i = 1 to numCards
  21. >    go card i of stack "sourceStack"
  22. >    put field "f1" into f1contents
  23. >    - and so on
  24. >  
  25. >  go stack "destination" - has one card to begin with, with fields, etc
  26. >  if i > the number of cards then
  27. >    doMenu "New Card"
  28. >  end if
  29. >  go card i
  30. >
  31. >  put f1contents into field "f1" - fields have same names
  32. >  - and so on
  33. >
  34. > end repeat
  35. >end copyStuff
  36.  
  37. I think the problem is that when you do go stack "destination" and make the
  38. new card, the card goes after the current card (the current card being the
  39. first card when just entering the stack).  Then you go to the i'th card,
  40. but that isn't the one you just created.
  41.  
  42. One way to fix the problem is to:
  43.  
  44.    go last card of stack "destination"
  45.    if i > the number of cards then
  46.       doMenu "New Card"
  47.    end if
  48.    put f1contents into field "f1"
  49.  
  50. I have a stack that is used by a group of consultants here at the computer
  51. center.  I've had to update the stack ump-teen times so I had a similar
  52. problem to yours.  I didn't want to have to go between stacks on each
  53. card, because of the additional overhead of opening and closing stacks.
  54. What I did was to write a text file having the information of the source
  55. stack, then go to the destination stack and read the stuff back in.  The
  56. code looked something like:
  57.  
  58. - This is all from memory so if the syntax is a little off, forgive me
  59.  
  60. on dump
  61.     open file "Temp File"
  62.     put tab into fieldSeparator
  63.     put return into cardSeparator
  64.     go first card
  65.     repeat with i = 1 to the number of cards
  66.       get field "f1" && fieldSeparator && field "f2" && cardSeparator
  67.       write it to file "Temp File"
  68.       go next card
  69.     end repeat
  70.     close file "Temp File"
  71. end dump
  72.  
  73. on restore
  74.     open file "Temp File"
  75.     put tab into fieldSeparator
  76.     put return into cardSeparator
  77.     read file "Temp File" until cardSeparator
  78.     repeat until it is empty
  79.       doMenu "New Card"
  80.       put offset(fieldSeparator,it) into endOfRecord
  81.       if endOfRecord > 1
  82.       then put char 1 to (endOfRecord - 1) of it into field "f1"
  83.       delete char 1 to endOfRecord of it
  84.       put offset(fieldSeparator,it) into endOfRecord
  85.       if endOfRecord > 1
  86.       then put char 1 to (endOfRecord - 1) of it into field "f2"
  87.       read file "Temp File" until cardSeparator
  88.     end repeat
  89.     close file "Temp File"
  90. end restore
  91.  
  92. I would do "dump" in the source stack and then go to the destination stack
  93. and do "restore".  In my stack, I had some 20 fields and it took about
  94. 6-8 seconds to write out each card and about 1-2 seconds to read it back
  95. in.
  96.  
  97. I eventually wanted the intermediate output to be a way to transfer data
  98. to Unix systems, where I have a simple program that can create and edit
  99. the data which could be read into the stack.  This made it considerable
  100. more complicated and (for some reason) writing it out took 2-4 seconds
  101. and reading it back in took 6-10 seconds (it has to recognize various
  102. key words, since the fields could come in any order).  This was much
  103. too slow for what I had to do.  I finally wrote an XFCN that did the
  104. same thing in C, and now it takes a second or less to write out a card,
  105. and a second or two to read it back in.
  106.  
  107.  
  108.  
  109. -- part contents for background part 45
  110. ----- text -----
  111. Re: Copying contents of stacks